package com.panshi.vo;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {

    /*是否成功*/
    private boolean success;
    /*状态码*/
    private Integer code;
    /*返回消息*/
    private String msg;
    /*返回数据*/
    private T data;

    //成功
    public Result<T> ok(){
        this.setSuccess(true);
        this.setCode(ResultCode.SUCCESS);
        this.setMsg("成功");
        return this;
    }

    //失败
    public Result<T> error(){
        this.setSuccess(false);
        this.setCode(ResultCode.ERROR);
        this.setMsg("失败");
        return this;
    }

    public Result<T> success(Boolean success){
        this.setSuccess(success);
        return this;
    }

    public Result<T> code(Integer code){
        this.setCode(code);
        return this;
    }

    public Result<T> msg(String msg){
        this.setMsg(msg);
        return this;
    }



}
